package com.example.hibernate.program;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "EMPLOYEES", schema = "HB")
public class Employee implements Serializable {

	@EmbeddedId
	private LoginName loginName;

	@Column(name = "HIRE_DATE")
	private Date hireDate;

	public LoginName getLoginName() {
		return loginName;
	}

	public void setLoginName(LoginName loginName) {
		this.loginName = loginName;
	}

	public Date getHireDate() {
		return hireDate;
	}

	public void setHireDate(Date hireDate) {
		this.hireDate = hireDate;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((loginName == null) ? 0 : loginName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj == null) return false;
		if (getClass() != obj.getClass()) return false;
		Employee other = (Employee) obj;
		if (loginName == null) {
			if (other.loginName != null) return false;
		} else if (!loginName.equals(other.loginName)) return false;
		return true;
	}

	@Override
	public String toString() {
		return "Employee [loginName=" + loginName + ", hireDate=" + hireDate + "]";
	}

}
